revBrowserAddJavaScriptHandler
Type
command
Summary
Adds the named handler to the 'LiveCode' object within the current JavaScript context of the browser.
Syntax
revBrowserAddJavaScriptHandler <instanceID>, <handlerName>
Description
The revBrowserAddJavaScriptHandler adds the named handler to the 'LiveCode' object within the current JavaScript context of the browser.
The revBrowserAddJavaScriptHandler function will make the named LiveCode handler visible to JavaScript within the browser as a function belonging to the global JavaScript 'LiveCode' object. Calling this JavaScript function will result in a call to the LiveCode handler, which will be passed the browser instance as the first parameter followed by any parameters given to the JavaScript function.
A LiveCode card has the following handler:
on myLiveCodeHandler pID, pArg1, pArg2
answer \"Browser ID\" && pID &&
\"called myLiveCodeHandler with arguments\" && pArg1 && \"and\" && pArg2
end myLiveCodeHandler
Registered within the JavaScript context with the following command:
revBrowserAddJavaScriptHandler tBrowserID, \"myLiveCodeHandler\"
The JavaScript code within the browser can then call the LiveCode handler via the registered function:
if (tIsRevBrowser)
liveCode.myBrowserHandler(tValue1, tValue2);
Parameters
Name | Type | Description |
---|---|---|
instanceID | the ID of the browser instance returned by the revBrowserOpen function. | |
handlerName | the name of a LiveCode handler in the script of the card / stack displaying the browser. |
Examples
local tBrowserID
put revBrowserOpenCef(the windowId \
of this stack, "http://www.livecode.com" ) into tBrowserID
revBrowserAddJavaScriptHandler tBrowserID, "myLiveCodeHandler"
Related
command: revBrowserStop, revBrowserPrint, revBrowserSet, revBrowserMakeTextBigger, revBrowserNavigate, revBrowserRemoveJavaScriptHandler, revBrowserClose
function: revBrowserOpen, revBrowserOpenCef
message: browserOver, browserNewInstance, browserNewUrlWindow, browserDownloadRequest, browserNavigateCompleteFrame
Compatibility and Support
Introduced
LiveCode 6.7
OS
mac
windows
Platforms
desktop